package jdbctest;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.Statement;

/**
 * @author tongchen
 * @create 2022-11-03 16:55
 */
public class JdbcTest {
    public static void main(String[] args) throws Exception {
        //1.注册驱动
        Class.forName("com.mysql.jdbc.Driver");
        //2.获取连接
        String url="jdbc:mysql://127.0.0.1:3306/exer?useSSL=false";
        String username="root";
        String passworrd="abc123";
        Connection conn = DriverManager.getConnection(url, username, passworrd);
        //3.定义sql语句
        String sql="update account set money=2000 where name ='张三'";
        //4.获取sql对象
        Statement statement = conn.createStatement();
        //5.执行sql语句
        int i = statement.executeUpdate(sql);
        //6.处理返回结果
        System.out.println(i);
        //7.释放资源
        statement.close();
        conn.close();

    }
}
